#ifndef _CCHARACTER_H
#define _CCHARACTER_H

#include "CAnimatedObject.h"
#include "Equipment.h"
#include "Global variables.h"
#include "CTexture.h"



typedef bool (*COLLISIONCHECKING) ( CAnimatedObject *pObject , LPVOID pContext );

class CCharacter : public CAnimatedObject
{
public:
	//--------------------------------------------//
	//	Constructor and Destructor for this class //
	//--------------------------------------------//
	CCharacter();
	CCharacter( float Xpos , float Ypos , float deep , float XVelocity , float YVelocity , int width , int height );
	virtual ~CCharacter();


	//----------------------//
	// Enum : CALLBACK TYPE	//
	//----------------------//
	enum CALLBACK_TYPE { CALLBACK_TYPE_COLLISION = 0 ,
							CALLBACK_TYPE_ACTIVE = 1 ,
							CALLBACK_COUNT = 2 };

	//----------------------//
	//	Enum : DIRECTION	//
	//----------------------//
	enum DIRECTION { DIR_RIGHT = 1 ,
						DIR_LEFT = 2 ,
						DIR_UP = 4 ,
						DIR_DOWN = 8 ,
						DIR_FORCE_DWORD = 0x7fffffff};


	//------------------------------------------//
	// Struct : Custom bound box information	//
	//------------------------------------------//
	struct CUSTOM_BOUND_BOX
	{
		float	offsetX;
		float	offsetY;
		int		width;
		int		height;
		int		offsetMove;
		int		relatedIndex;

		CUSTOM_BOUND_BOX( float offX , float offY , int sizeWidth , int sizeHeight , int offMove , int refIndex )
		{
			offsetX			= offX;
			offsetY			= offY;
			width			= sizeWidth;
			height			= sizeHeight;
			offsetMove		= offMove;
			relatedIndex	= refIndex;
		}

		CUSTOM_BOUND_BOX()
		{
			offsetX			= 0;
			offsetY			= 0;
			width			= 0;
			height			= 0;
			offsetMove		= 0;
			relatedIndex	= 0;
		}
	};

	//--------------------------------//
	//	Public methods for this class //
	//--------------------------------//
	void		SetLv					( int lev );
	void		SetMaxAttribute			( int maxHp , int maxMp );
	void		SetCurrAttribute		( int currHp , int currMp );
	void		SetDamage				( int minDamage , int maxDamage );
	void		SetDefend				( int def );
	void		SetWeapon				( WEAPON *weapon );
	void		SetArmor				( ARMOR *armor );
	void		SetDirection			( DIRECTION dir );
	void		SetDying				( bool isDying = true );

	int			GetMaxHp				( );
	int			GetMaxMp				( );
	int			GetHp					( );
	int			GetMp					( );
	int			GetMinDamage			( );
	int			GetMaxDamage			( );
	int			GetDef					( );
	int			GetLv					( );
	float		GetPercentHp			( );
	float		GetPercentMp			( );
	bool		isDying					( );
	DIRECTION	GetCurrentDir			( );
	void		RegisterCallback		( CALLBACK_TYPE Type , LPVOID pFunc , LPVOID pContext );
	void		ReduceHp				( int damgTaken );
	void		ReduceMp				( int manaTaken );

	virtual int		DamageCal			( );
	virtual void	Init				( LPCTSTR DefineFile){ };	

private:
	//-----------------------------------//
	//	Private variables for this class //
	//-----------------------------------//
	int				 m_iMaxHp;
	int				 m_iMaxMp;
	int				 m_iHp;
	int				 m_iMp;

	int				 m_iMinDamage;
	int				 m_iMaxDamage;
	int				 m_iDefend;
	int				 m_iLevel;

	bool			 m_isDying;			// The character is dying or not !!
										// This variables for making some dying effect

	DIRECTION		 m_CurrentDir;		// Current direction of this character

protected:
	CALLBACK_FUNC	 m_CallBack[CALLBACK_COUNT];
	WEAPON			*m_pWeapon;
	ARMOR			*m_pArmor;
};


#endif